<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
abstract class CI_Session_driver implements SessionHandlerInterface
{
	protected $_config;
	/**
	 * Data fingerprint
	 *
	 * @var	bool
	 */
	protected $_fingerprint;
	/**
	 * Lock placeholder
	 *
	 * @var	mixed
	 */
	protected $_lock = false;
	/**
	 * Read session ID
	 *
	 * Used to detect session_regenerate_id() calls because PHP only calls
	 * write() after regenerating the ID.
	 *
	 * @var	string
	 */
	protected $_session_id;
	/**
	 * Success and failure return values
	 *
	 * Necessary due to a bug in all PHP 5 versions where return values
	 * from userspace handlers are not handled properly. PHP 7 fixes the
	 * bug, so we need to return different values depending on the version.
	 *
	 * @see	https://wiki.php.net/rfc/session.user.return-value
	 * @var	mixed
	 */
	protected $_success;
	protected $_failure;

	public function __construct(&$params)
	{
		$this->_config = &$params;

		if (is_php('7')) {
			$this->_success = true;
			$this->_failure = false;
		}
		else {
			$this->_success = 0;
			$this->_failure = -1;
		}
	}

	protected function _cookie_destroy()
	{
		return setcookie($this->_config['cookie_name'], NULL, 1, $this->_config['cookie_path'], $this->_config['cookie_domain'], $this->_config['cookie_secure'], true);
	}

	protected function _get_lock($session_id)
	{
		$this->_lock = true;
		return true;
	}

	protected function _release_lock()
	{
		if ($this->_lock) {
			$this->_lock = false;
		}

		return true;
	}

	protected function _fail()
	{
		ini_set('session.save_path', config_item('sess_save_path'));
		return $this->_failure;
	}
}

?>
